source('00_util_scripts/mod_seurat.R')
source('00_util_scripts/mod_bplot.R')

proj.nm <- 'mission/SLE_TRPM2_MfMo/'

sobj <- read_rds('mission/FPP/zww_sa_mice/data/aureus_mice_skin.rds')

canon_mark <- c('Cd3a')

sobj |>
  DotPlot(group.by = 'manual_main', cols = 'RdYlBu')

sobj |>
  DotPlot2d('Trpm2', orig.ident, manual_main) +
  labs(x = 'Group', y = 'Cell type',
       title = 'Trpm2 in murine skin')

sobj |>
  DotPlot2d('Cd14', orig.ident, manual_main) +
  labs(x = 'Group', y = 'Cell type',
       title = 'Cd14 in murine skin')

sobj |>
  DotPlot2d('Tnf', orig.ident, manual_main) +
  labs(x = 'Group', y = 'Cell type',
       title = 'Tnf in murine skin')

sobj |>
  DotPlot2d('Ccr2', orig.ident, manual_main) +
  labs(x = 'Group', y = 'Cell type',
       title = 'Ccr2 in murine skin')

sobj |>
  DotPlot2d('Hmgb2', orig.ident, manual_main) +
  labs(x = 'Group', y = 'Cell type',
       title = 'Hmgb2 in murine skin')


sobj |> DimPlot(group.by = 'manual_main', cols = 'Paired')

sobj |>
  DotPlot(c('Adgre1','Marco','S100a8','Ly6g','Mpo','Xcr1','Clec9a'),
          cols = 'RdBu', group.by = 'manual_main')

gene_of_int <- c('Cd14','Ccr2','Hmgb2','Trpm2','Tnf')

goi_savpbs <- sobj |>
  FindMarkersAcrossVar(split.by = 'manual_main', group.by = 'orig.ident',
                       ident.1 = 'infected', features = gene_of_int)

goi_savpbs |>
  ggplot(aes(gene, cluster, fill = avg_log2FC, size = -log(p_val_adj))) +
  geom_point(shape = 21) +
  theme_bw() +
  scale_fill_distiller(palette = 'RdBu',
                       values = pretty_distiller(goi_savpbs$avg_log2FC)) +
  scale_radius(range = c(0,6)) +
  labs(title = 'Differential gene expression SA vs PBS', y = 'Cell type')

goi_savpbs |>
  ggplot(aes(gene, cluster, fill = avg_log2FC)) +
  geom_tile(color = 'black') +
  theme_minimal() +
  scale_fill_distiller(palette = 'RdYlBu',
                       values = pretty_distiller(goi_savpbs$avg_log2FC))
